package com.xctech.yace.swing.component;

import lombok.Data;

import javax.swing.*;
import java.awt.*;

@Data
public class ComboboxToolTipRenderer  extends DefaultListCellRenderer {

    public Component getListCellRendererComponent(JList list, Object value,
                                                  int index, boolean isSelected, boolean cellHasFocus) {

        JComponent comp = (JComponent) super.getListCellRendererComponent(list,
                value, index, isSelected, cellHasFocus);

        if (comp instanceof JLabel) {
            JLabel label = (JLabel) comp;
            label.setToolTipText((String) value);
        }
        return comp;
    }
}
